package com.maxjay.system.web.controller.struts;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.maxjay.common.util.json.JsonParser;
import com.maxjay.system.core.cache.BufferedDictTableUtils;
import com.maxjay.system.model.DictTab;

public class DictOptionsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DictOptionsServlet() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String codeTab = request.getParameter("codeTab");
		DictTab dictTab = BufferedDictTableUtils.getDictTab(codeTab);
		response.setCharacterEncoding("UTF-8");
		response.getWriter().write(JsonParser.convertArrayToJson(dictTab.getDictCodes()));
	}
	
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
